import request from '@/utils/request'
import axios from 'axios'
import qs from 'qs'
export function listCoupon(query) {
 return axios.get('http://localhost:8096/coupons/selCouponsTemp', {
   params: query
 })
}

export function createCoupon(data) {
  return request({
    url: '/coupon/create',
    method: 'post',
    data
  })
}

export function readCoupon(id) {
  return request({
    url: '/coupon/read',
    method: 'get',
    params: { id }
  })
}

export function getScopeList() {
  return axios.get('http://localhost:8096/coupons/getScopeList')

}

export function updateCoupon(data) {

 return request({
    'url': 'http://localhost:8096/coupons/UpdataCoupen',
    'method': 'post',
    'Headers':{'Content-Type':'application/json;charset=utf8'},
    'data':qs.stringify(data,{arrayFormat:'brackets'})
  })

}

export function deleteCoupon(data) {
  return request({
    'url': '/coupons/delete',
    'method': 'post',
    'Headers':{'Content-Type':'application/json;charset=utf8'},
    'data':data
  })
}

export function listCouponUser(query) {
  return request({
    url: '/coupon/listuser',
    method: 'get',
    params: query
  })
}
